OleAutoObj and "Object Text"

Hi all,

Is there a reason why you cannot set an object's "Object Text" property to an OleAutoObj?

I have a shape object that I'm trying to put into the current object's "Object Text" property, but it won't allow this.

Thanks,
Mark
meherts - Thu Jul 29 11:20:47 EDT 2010

Re: OleAutoObj and "Object Text"
Mathias Mamsch - Fri Jul 30 06:01:55 EDT 2010

Without example code, it is hard to say why it fails, but did you maybe forget to cast to the "Object Text" to string ?
 

// not like this!
     // olePut (objShape, "Text", obj."Object Text" )
 
     // cast to string, by appending an empty string.
     olePut(objShape, "Text", obj."Object Text" "")

 


Maybe it helps. Regards, Mathias

 

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

 

Re: OleAutoObj and "Object Text"
meherts - Fri Jul 30 09:37:21 EDT 2010

Mathias Mamsch - Fri Jul 30 06:01:55 EDT 2010

Without example code, it is hard to say why it fails, but did you maybe forget to cast to the "Object Text" to string ?
 

// not like this!
     // olePut (objShape, "Text", obj."Object Text" )
 
     // cast to string, by appending an empty string.
     olePut(objShape, "Text", obj."Object Text" "")

 


Maybe it helps. Regards, Mathias

 

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

 

Hello Mathias!,

So, let me explain what I'm trying to do. Firstly, here's the function I use to grab an individual shape by name:
 

OleAutoObj getShape(string name){
        //Create variables
        string str = ""
        int flag = 0
        int i = 1
 
        //Grab shapes
        oleGet(objSheet, cPropertyShapes, objShapes)
        if(null objShapes) {print "No shapes collection found ...\n"; halt;}
 
        //Create argument
        OleAutoArgs autoArgs = create
        while(flag = 0){
                put(autoArgs, i)
 
                //Get individual shape
                oleMethod(objShapes, cMethodItem, autoArgs, objShape)
                if(null objShape){ print "Cannot find shape ...\n"; halt;}
 
                //Get name
                oleGet(objShape, cPropertyName, str)
                if(name == str){ flag = 1;}
                else {i = i + 1;}
 
                //Clear args
                clear(autoArgs)
        }
        //Return shape object
        return objShape
}


 


Now, that function works perfectly. So, here's the code that's calling it:

 

 

 

OleAutoObj objShape = getShape("MyPicture")



So, now I have an auto object, and I want to take this object and put it into the current object's text. Essentially, I want this picture to be imported into DOORS.

Need more information? By the way, thank you for taking the time to help me Mathias, it's much appreciated!

Regards,
Mark



 

 

Re: OleAutoObj and "Object Text"
Mathias Mamsch - Sun Aug 01 05:53:46 EDT 2010

meherts - Fri Jul 30 09:37:21 EDT 2010

Hello Mathias!,

So, let me explain what I'm trying to do. Firstly, here's the function I use to grab an individual shape by name:
 

OleAutoObj getShape(string name){
        //Create variables
        string str = ""
        int flag = 0
        int i = 1
 
        //Grab shapes
        oleGet(objSheet, cPropertyShapes, objShapes)
        if(null objShapes) {print "No shapes collection found ...\n"; halt;}
 
        //Create argument
        OleAutoArgs autoArgs = create
        while(flag = 0){
                put(autoArgs, i)
 
                //Get individual shape
                oleMethod(objShapes, cMethodItem, autoArgs, objShape)
                if(null objShape){ print "Cannot find shape ...\n"; halt;}
 
                //Get name
                oleGet(objShape, cPropertyName, str)
                if(name == str){ flag = 1;}
                else {i = i + 1;}
 
                //Clear args
                clear(autoArgs)
        }
        //Return shape object
        return objShape
}


 


Now, that function works perfectly. So, here's the code that's calling it:

 

 

 

OleAutoObj objShape = getShape("MyPicture")



So, now I have an auto object, and I want to take this object and put it into the current object's text. Essentially, I want this picture to be imported into DOORS.

Need more information? By the way, thank you for taking the time to help me Mathias, it's much appreciated!

Regards,
Mark



 

 

You just need to use the "Copy" method on the shape object and do an olePaste(Attr_) to the attribute you want to import into. I don't know if there is a way without using the clipboard. You can convert an EmbeddedOleObject into an OleAutoObj but I think it is not possible the other way around. You can also use this approach to create OLE objects from scratch, for example an excel chart or a visio diagram. This is most useful for generating reports in DOORS.

This code will import (copy/paste) the first picture in the currently active excel sheet into the Object Text of the current Object.

Regards, Mathias
 

OleAutoObj objEx = oleGetAutoObject("Excel.Application") 
 
if (null objEx) { print "Please open Excel!"; halt }
 
OleAutoObj objSheet = null 
 
oleGet(objEx, "ActiveSheet", objSheet)
if (null objEx) { print "Cannot find sheet. Please open a workbook!"; halt }
 
string s
oleGet(objSheet, "Name", s) 
print "Worksheet Name: " s "\n"
 
OleAutoObj objShapes
oleGet(objSheet, "Shapes", objShapes)
if (null objShapes) { print "That is weird. No shapes collection found ..."; halt }
 
OleAutoArgs args = create()
put(args, 1) 
 
OleAutoObj objShape
oleMethod(objShapes, "Item", args, objShape) 
if (null objShape) { print "Cannot find Shape. Please insert a clipart to the active worksheet!"; halt }
 
oleGet(objShape, "Name", s) 
print "Picture Name: " s "\n"
 
print oleMethod(objShape, "Copy")
olePaste (current Object)."Object Text"

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

Re: OleAutoObj and "Object Text"
Mathias Mamsch - Sun Aug 01 05:57:24 EDT 2010

meherts - Fri Jul 30 09:37:21 EDT 2010

Hello Mathias!,

So, let me explain what I'm trying to do. Firstly, here's the function I use to grab an individual shape by name:
 

OleAutoObj getShape(string name){
        //Create variables
        string str = ""
        int flag = 0
        int i = 1
 
        //Grab shapes
        oleGet(objSheet, cPropertyShapes, objShapes)
        if(null objShapes) {print "No shapes collection found ...\n"; halt;}
 
        //Create argument
        OleAutoArgs autoArgs = create
        while(flag = 0){
                put(autoArgs, i)
 
                //Get individual shape
                oleMethod(objShapes, cMethodItem, autoArgs, objShape)
                if(null objShape){ print "Cannot find shape ...\n"; halt;}
 
                //Get name
                oleGet(objShape, cPropertyName, str)
                if(name == str){ flag = 1;}
                else {i = i + 1;}
 
                //Clear args
                clear(autoArgs)
        }
        //Return shape object
        return objShape
}


 


Now, that function works perfectly. So, here's the code that's calling it:

 

 

 

OleAutoObj objShape = getShape("MyPicture")



So, now I have an auto object, and I want to take this object and put it into the current object's text. Essentially, I want this picture to be imported into DOORS.

Need more information? By the way, thank you for taking the time to help me Mathias, it's much appreciated!

Regards,
Mark



 

 

You just need to use the "Copy" method on the shape object and do an olePaste(Attr_) to the attribute you want to import into. I don't know if there is a way without using the clipboard. You can convert an EmbeddedOleObject into an OleAutoObj but I think it is not possible the other way around. You can also use this approach to create OLE objects from scratch, for example an excel chart or a visio diagram. This is most useful for generating reports in DOORS.

This code will import (copy/paste) the first picture in the currently active excel sheet into the Object Text of the current Object.

Regards, Mathias
 

OleAutoObj objEx = oleGetAutoObject("Excel.Application") 
 
if (null objEx) { print "Please open Excel!"; halt }
 
OleAutoObj objSheet = null 
 
oleGet(objEx, "ActiveSheet", objSheet)
if (null objEx) { print "Cannot find sheet. Please open a workbook!"; halt }
 
string s
oleGet(objSheet, "Name", s) 
print "Worksheet Name: " s "\n"
 
OleAutoObj objShapes
oleGet(objSheet, "Shapes", objShapes)
if (null objShapes) { print "That is weird. No shapes collection found ..."; halt }
 
OleAutoArgs args = create()
put(args, 1) 
 
OleAutoObj objShape
oleMethod(objShapes, "Item", args, objShape) 
if (null objShape) { print "Cannot find Shape. Please insert a clipart to the active worksheet!"; halt }
 
oleGet(objShape, "Name", s) 
print "Picture Name: " s "\n"
 
print oleMethod(objShape, "Copy")
olePaste (current Object)."Object Text"

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

Re: OleAutoObj and "Object Text"
meherts - Mon Aug 02 09:26:56 EDT 2010

Mathias Mamsch - Sun Aug 01 05:57:24 EDT 2010

You just need to use the "Copy" method on the shape object and do an olePaste(Attr_) to the attribute you want to import into. I don't know if there is a way without using the clipboard. You can convert an EmbeddedOleObject into an OleAutoObj but I think it is not possible the other way around. You can also use this approach to create OLE objects from scratch, for example an excel chart or a visio diagram. This is most useful for generating reports in DOORS.

This code will import (copy/paste) the first picture in the currently active excel sheet into the Object Text of the current Object.

Regards, Mathias
 

OleAutoObj objEx = oleGetAutoObject("Excel.Application") 
 
if (null objEx) { print "Please open Excel!"; halt }
 
OleAutoObj objSheet = null 
 
oleGet(objEx, "ActiveSheet", objSheet)
if (null objEx) { print "Cannot find sheet. Please open a workbook!"; halt }
 
string s
oleGet(objSheet, "Name", s) 
print "Worksheet Name: " s "\n"
 
OleAutoObj objShapes
oleGet(objSheet, "Shapes", objShapes)
if (null objShapes) { print "That is weird. No shapes collection found ..."; halt }
 
OleAutoArgs args = create()
put(args, 1) 
 
OleAutoObj objShape
oleMethod(objShapes, "Item", args, objShape) 
if (null objShape) { print "Cannot find Shape. Please insert a clipart to the active worksheet!"; halt }
 
oleGet(objShape, "Name", s) 
print "Picture Name: " s "\n"
 
print oleMethod(objShape, "Copy")
olePaste (current Object)."Object Text"

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

THANK YOU SO MUCH MATHIAS! It worked BEAUTIFULLY! Really, you have my utmost appreciation ... truly.

Thank you once again,
Mark

Re: OleAutoObj and "Object Text"
SystemAdmin - Fri Sep 09 05:41:47 EDT 2011

Mathias Mamsch - Sun Aug 01 05:57:24 EDT 2010

You just need to use the "Copy" method on the shape object and do an olePaste(Attr_) to the attribute you want to import into. I don't know if there is a way without using the clipboard. You can convert an EmbeddedOleObject into an OleAutoObj but I think it is not possible the other way around. You can also use this approach to create OLE objects from scratch, for example an excel chart or a visio diagram. This is most useful for generating reports in DOORS.

This code will import (copy/paste) the first picture in the currently active excel sheet into the Object Text of the current Object.

Regards, Mathias
 

OleAutoObj objEx = oleGetAutoObject("Excel.Application") 
 
if (null objEx) { print "Please open Excel!"; halt }
 
OleAutoObj objSheet = null 
 
oleGet(objEx, "ActiveSheet", objSheet)
if (null objEx) { print "Cannot find sheet. Please open a workbook!"; halt }
 
string s
oleGet(objSheet, "Name", s) 
print "Worksheet Name: " s "\n"
 
OleAutoObj objShapes
oleGet(objSheet, "Shapes", objShapes)
if (null objShapes) { print "That is weird. No shapes collection found ..."; halt }
 
OleAutoArgs args = create()
put(args, 1) 
 
OleAutoObj objShape
oleMethod(objShapes, "Item", args, objShape) 
if (null objShape) { print "Cannot find Shape. Please insert a clipart to the active worksheet!"; halt }
 
oleGet(objShape, "Name", s) 
print "Picture Name: " s "\n"
 
print oleMethod(objShape, "Copy")
olePaste (current Object)."Object Text"

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

Hi Mathias,

I am new in Door I want copy text from excel file and paste into Object Text of the current Object
same like the following example

Please give me DXL code

Re: OleAutoObj and "Object Text"
OurGuest - Fri Sep 09 06:17:05 EDT 2011

SystemAdmin - Fri Sep 09 05:41:47 EDT 2011
Hi Mathias,

I am new in Door I want copy text from excel file and paste into Object Text of the current Object
same like the following example

Please give me DXL code

Mathias Mamsch

Looks like here is a call for you speech again. go for it.

Re: OleAutoObj and "Object Text"
Mathias Mamsch - Fri Sep 09 07:20:42 EDT 2011

OurGuest - Fri Sep 09 06:17:05 EDT 2011
Mathias Mamsch

Looks like here is a call for you speech again. go for it.

;-) the user "Bosch" has pulled old stuff already in the past and at least this guy has chosen a post remotely connected with what he wants to accomplish. Anyway there are several posts in the forum on importing from Excel. Searching for "import Excel" got me the following results. Maybe those threads will help you:

https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14618865&#14618865
https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14487281&#14487281

By the way: I only very rarely answer requests which ask something like: "I have no idea of DXL, I need <DXL Program X>, please give me the code". If you want to learn DXL in this forum you can find a wealth of information. Try to start your own example, post it and we will improve it together.

Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Re: OleAutoObj and "Object Text"
PatrickGuay - Mon Sep 12 13:50:40 EDT 2011

I am trying to set the name of the excel file to a given module name as well as name the sheet while exporting from DOORS to excel (export_to_excel.dxl). However, The default behavior is creating an excel file named "Book1" with a sheet "Sheet1".

I have modified the script in order to add a file chooser DBE in the data sheet GUI tab. The loaded configuration file is a list of modules to export to excel. Presently, I am able to create as many excel files as there are modules in my configuration file however, I would like to regroup all the seperate files in a single file.

Also, if I try to select datasheet 4 or 5 (any number greater than 3. The script will not let me and re-routes my export to data sheet 1... I may have 50 modules to export and I want to create as many data sheets as modules in my configuration file)

Any suggestions or leads will help in my understanding of this script.